/** \file 
 *	\brief OpenCL common types and definitions
 */

#ifndef OCL_TYPES_INCLUDED
#define OCL_TYPES_INCLUDED 1

#include "../mds/types.h"

#if defined(__APPLE__)
#	include <OpenCL/cl.h>
#	define OCL_CALLBACK
#else
#	include <CL/cl.h>
#	define OCL_CALLBACK CL_CALLBACK
#endif

extern FILE  *ocl_logfile;
extern cl_int ocl_errno;

#if MDS_DOUBLE == 1
typedef cl_double2 Real2;
typedef cl_double4 Real4;
typedef cl_double8 Real8;
#else
typedef cl_float2  Real2;
typedef cl_float4  Real4;
typedef cl_float8  Real8;
#endif



/** \brief Converts OpenCL error code into a C string
 *	
 *	\param err an OpenCL error code
 */
const char * ocl_strerror(const cl_int err);

/** \brief Formatted error logging.
 *
 *	\param fp   a valid FILE pointer.
 *	\param err  if err == CL_SUCCESS, it will display errno
 *	\param when a printf format string
 */
void         ocl_perror( FILE *fp, const char *when,...) MDS_LIKE_PRINTF(2,3);
#endif
